#include "predicates.h"
#include <iterator>

class triangle_iterator: public std::iterator<std::input_iterator_tag, point>
{
    int min_x, max_x, x, y;
    double next_min_y, next_max_y, min_y, max_y, bound;
    bool crossed, crossed_next, finished, new_column;
    segment segm12, segm13, segm23;

    point current_cell;

    void check_minmax_y(const segment&, int);
    void first_check(const segment&);
    void count_new_column();
    double y_at_wrapper(const segment&, int) const;

public:
    triangle_iterator(const segment& _segm12, const segment& _segm23, const segment& _segm13, bool _finished);
    triangle_iterator(const segment&, const segment&, const segment&);

    const point& operator*() { current_cell = point(x, y); return current_cell; }
    triangle_iterator& operator++();

    bool operator !=(const triangle_iterator&) const;
    bool operator ==(const triangle_iterator&) const;
};